/**
 * 
 */
package com.orisper.omp.modules.product;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.orisper.dao.Bm_productDao;
import com.orisper.dao.Bm_productPO;

import aos.framework.core.id.AOSId;
import aos.framework.core.typewrap.Dto;
import aos.framework.core.utils.AOSJson;
import aos.framework.web.router.HttpModel;
import aos.system.common.service.AOSBaseService;

/**
 * @author Administrator
 *
 */
@Service
public class ProductService extends AOSBaseService{
	
	@Autowired
	Bm_productDao bm_productDao;
	
	
	/**
	 * 产品页面初始化
	 * 
	 * @param httpModel
	 * @return
	 */
	public void init(HttpModel httpModel) {
		httpModel.setAttribute("juid", httpModel.getInDto().getString("juid"));
		httpModel.setViewPath("project/orisper/productManage.jsp");
	}

	
	/**
	 * 查询产品列表
	 * 
	 * @param httpModel
	 */
	public void list(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		List<Dto> list = sqlDao.list("Product.listPage",inDto);
		httpModel.setOutMsg(AOSJson.toGridJson(list, inDto.getPageTotal()));
	}
	
	/**
	 * 查询产品列表
	 * 
	 * @param httpModel
	 */
	public void getProductInfo(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_productPO bm_productPO=bm_productDao.selectByKey(inDto.getString("id"));
		httpModel.setOutMsg(AOSJson.toJson(bm_productPO));
	}
	
	/**
	 * 修改产品信息
	 * 
	 * @param httpModel
	 */
	public void updateProductInfo(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_productPO bm_productPO = new Bm_productPO();
		bm_productPO.copyProperties(inDto);
		bm_productPO.setModify_date(new Date());
		bm_productDao.updateByKey(bm_productPO);
		httpModel.setOutMsg("修改成功");
	}
	
	
	
	
	/**
	 * 添加产品信息
	 * 
	 * @param httpModel
	 */
	public void addProductInfo(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_productPO bm_productPO = new Bm_productPO();
		bm_productPO.copyProperties(inDto);
		bm_productPO.setId(AOSId.uuid());
		bm_productPO.setCreate_date(new Date());
		bm_productDao.insert(bm_productPO);
		httpModel.setOutMsg("添加成功");
	}
	
	
	
	
}
